package cn.gson.boot.model.dao;

import cn.gson.boot.model.pojos.Hetong;
import cn.gson.boot.model.pojos.Hetongxiangqing;
import cn.gson.boot.model.pojos.Quotation;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;
import java.util.List;

public interface HeTongXiangQingDao extends CrudRepository<Hetongxiangqing,Integer> {

    //查看合同详情根据合同id
    @Query(nativeQuery = true,value = "select * from hetongxiangqing where ht_id = ?1")
    public List<Hetongxiangqing> ckHeTongXiangQing(Integer khid);

    //修改后台时会重复新增合同详情，所以先根据合同id删除一下
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "delete from hetongxiangqing where ht_id = ?1")
    public void deleteHeTongXiangQing(Integer khid);

}
